<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title></title>
		<style>
			div{
				margin-top: -40px;
				margin-left: 300px;
			}
			
			a:link{
				padding: 0px 3px;
				background-color: azure;
				border: 1px solid gray;
				text-decoration: none;
			}
		</style>
		
		
	</head>
	<body>
		<img id="img1" width="400" height="300" src="img/2.jpg"/>
		<div>
			<a href="javascript:checkedImg(1)">1</a>
			<a href="javascript:checkedImg(2)">2</a>
			<a href="javascript:checkedImg(3)">3</a>
			<a href="javascript:checkedImg(4)">4</a>
		</div>
	</body>
</html>
<script>
			var index=1;
			var img1=document.getElementById('img1');
			var sid=setInterval('runImg()',2000);
			
			function runImg(){
				img1.src="img/"+index+".jpg";
				index=index==4?1:index+1;
			}
			
			function checkedImg(i){
				index=i;
				img1.src="img/"+index+".jpg";
				index=index==4?1:index+1;
				
				clearInterval(sid);
				sid=setInterval('runImg()',2000);
			}	
</script>